package pushup.controller;

import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.Status;
import org.eclipse.core.runtime.jobs.Job;

import pushup.model.Register;
import pushup.view.PushUpView;

public class SimilaritiesJob extends Job {
	private Register register;
	
	public SimilaritiesJob(Register register) {
		super("PushUp - Computing similarities");
		this.register = register;
		setUpJob();
	}
	
	public void setUpJob(){
		setUser(true);
		setPriority(LONG);
	}

	@Override
	protected IStatus run(IProgressMonitor monitor) {	
		monitor.beginTask("Computing similarities", register.getTypesWithSimilarities().size());
		
		register.computeSimilarities(monitor);
		
		PushUpView.openView();
		return Status.OK_STATUS;
	}

}
